<script lang="ts" setup>
import { ref } from "vue";
import Crud from "@/components/Crud/index.vue";

defineOptions({
  name: "自动页面渲染"
});
const props = defineProps({
  params: {
    type: Object
  },
  from_config: {
    type: Object,
    required: true,
    default: () => {
      return {
        columns: []
      };
    }
  },
  businessCode: {
    type: String,
    required: true
  }
});
const visible = ref(true);
const row = props.params.row;
// ============================业务操作========================================
const pageConfig = props.params.buttonRow.pageConfig;
const path = ref(pageConfig.code);
const search = ref({
  key: pageConfig.viceKey,
  value: row[`${props.businessCode}`][pageConfig.mainKey]
});
</script>

<template>
  <el-dialog
    v-model="visible"
    :title="props.params.text"
    :hasFooter="false"
    :width="props.params.buttonRow.pageConfig?.width ?? '80%'"
  >
    <Crud :path="path" :search_data="search" />
  </el-dialog>
</template>
